import 'package:flutter/cupertino.dart';
import 'package:get/get_state_manager/src/simple/get_controllers.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';

import '../../../hj_model/cartoon_media_info.dart';
import '../../../hj_model/home/home_tabs_entity.dart';
import '../../../hj_model/home/module_detail_model.dart';
import '../../../hj_model/video_model.dart';
import '../../main_page/provider/bottom_bar_provider.dart';

class HomeTabBaseLogic extends GetxController {
  final ModuleData tabModel;
  final int index;
  final bool isDarkStyle;
  HomeTabBaseLogic(this.index, this.tabModel, {this.isDarkStyle = false});

  int currentPage = 1;
  bool isLoadingData = true;
  ScrollController scrollController = ScrollController();
  RefreshController? refreshController;

  ModuleDetailModel? dataSource;
  List<CartoonMediaInfo> get allMedia => dataSource?.allMediaInfo ?? [];
  List<VideoModel> get allVideo => dataSource?.allVideoInfo ?? [];
  List<AllSection> get allSection => dataSource?.allSection ?? [];


  @override
  void onInit() {
    super.onInit();
    _onBottomTopIcon();
  }

  void _onBottomTopIcon() {
    if (isDarkStyle) {
      DarkwebBottomProvider().setSrollController(index, controller: scrollController);
    } else {
      HomeBottomProvider().setSrollController(index, controller: scrollController);
    }
  }
}
